Skip to content

fix(pageFilters): clear shift-click anchor on empty selection#115472

Open
priscilawebdev wants to merge 1 commit into
masterfrom
priscila/fix/staged-select-shift-click-empty-anchor
Open

fix(pageFilters): clear shift-click anchor on empty selection#115472
priscilawebdev wants to merge 1 commit into
masterfrom
priscila/fix/staged-select-shift-click-empty-anchor

Conversation

@priscilawebdev
Copy link
Copy Markdown
Member

The shift-click range selection in useStagedCompactSelect kept its anchor (lastSelected) pointing at the last clicked option even after the staged selection became empty. The next shift-click would then range-extend from that ghost anchor.

Repro (environment selector on the traces explorer)

With environments [A, B, C, D, E]:

  1. Shift-click A — selects [A], anchor = A
  2. Shift-click E — range-selects [A, B, C, D, E], anchor = E
  3. Shift-click E, D, C, B, A one by one — incrementally deselects the range; selection ends at [], but anchor lingers at A
  4. Shift-click C — expected [C], actual [A, B, C]

Fix

In the 'toggle' and 'toggle range' reducer cases, clear lastSelected to null whenever the resulting stagedValue is empty. The next shift-click then falls through the existing lastSelected === null branch, which already treats it as a regular single click (the same path used when the menu first opens).

A stricter check (treat the anchor as invalid whenever it's not in the current selection) was attempted but broke the existing 'deselects range when shift-clicking already selected item' test, which relies on a ctrl-clicked-off anchor still being usable for a range-deselect.

Added a unit test that walks through the exact repro above.

After deselecting every option via shift+click, the anchor lingered on
the last clicked item. The next shift+click would then range-extend from
that ghost anchor instead of acting as a fresh single click.

Clear lastSelected when the staged selection becomes empty so the next
shift+click falls through the existing null-anchor branch.
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.51%

@priscilawebdev priscilawebdev marked this pull request as ready for review May 13, 2026 10:59
@priscilawebdev priscilawebdev requested a review from a team as a code owner May 13, 2026 10:59
Copy link
Copy Markdown
Member

@JonasBa JonasBa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants